//
// GPSMapEdit
// (c) Konstantin Galichsky (kg@geopainting.com), 2002-2007
//
// Backup tool for actions not suppoting Undo() method.
//

# include "StdAfx.h"
# include "Resource.h"
# include "BackupAction.h"
# include "Status.h"
# include "Globals.h"

CBackupAction::~CBackupAction () {
	delete m_pAction;
}

void CBackupAction::GetName (string_t & _str) const {
	m_pAction->GetName (_str);
}

bool CBackupAction::Do () {
	CCritSec::CLock lock (g_cs);

	SetStatus (GetStr (IDS_STATUS_BACKING_UP));
	m_map = g_map;
	SetStatusReady ();

	g_map.swap (m_map);

	return m_pAction->Do ();
}

void CBackupAction::Undo () {
	CCritSec::CLock lock (g_cs);

	g_map.swap (m_map);
	m_pAction->Undo ();

	g_map.bDirtyRGNodes = true;
}

void CBackupAction::Redo () {
	CCritSec::CLock lock (g_cs);

	g_map.swap (m_map);
	m_pAction->Redo ();

	g_map.bDirtyRGNodes = true;
}

